package br.com.rhweb.beans;

import java.io.IOException;
import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

@Named
@ManagedBean(name="logarUsuarioBean")
@RequestScoped
public class LogarUsuarioBean implements Serializable{

	public String logarAtendenteConfirmacao(){
		ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
		RequestDispatcher rd = ((ServletRequest) context.getRequest()).getRequestDispatcher("/j_spring_security_check");
		try {
			rd.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		FacesContext.getCurrentInstance().responseComplete();
		return "confirmacao";
	}	
	
}
